//
//  ZWJCache.m
//  SmartWatch
//
//  Created by zwj on 2022/12/1.
//

#import "ZWJCache.h"

static NSString * const kUserInfo  = @"userInfo";    //!< 个人信息

@implementation UserInfo

@end

@implementation ZWJCache
// 是否登录
+ (BOOL)isLogin {
    NSDictionary *dic = [_userdefaults objectForKey:kUserInfo];
    return  [dic allKeys].count;
}


// 保存用户信息
+ (void)saveUserInfo:(UserInfo *)user{
    NSDictionary *dic = user.yy_modelToJSONObject;
    [_userdefaults setObject:dic forKey:kUserInfo];
    [_userdefaults synchronize];
}

// 获取用户信息
+ (UserInfo *)getUserInfo{
    NSDictionary *dic = [_userdefaults objectForKey:kUserInfo];
    UserInfo *user = [UserInfo yy_modelWithDictionary:dic];
    return user;
}
// 移除用户信息
+ (void)removeUserInfo{
    [_userdefaults setObject:@{} forKey:kUserInfo];
    [_userdefaults synchronize];
}
@end
